package com.gaga.metadata.convert;


import com.gaga.metadata.common.enums.DbOperatorType;
import com.gaga.metadata.common.utils.StringUtils;
import com.gaga.metadata.entity.database.DataBaseFilter;

/**
 * 操作符转换 MysqlFilterConvert
 *
 * @author lenovo
 */
public class MysqlFilterConvert extends AbstractFilterConvert<DataBaseFilter> {

    @Override
    public String convertOperatorType(DataBaseFilter filter) {
        String sqlCode = super.convertOperatorType(filter);
        if (StringUtils.isNotEmpty(sqlCode)){
            return sqlCode;
        }
        DbOperatorType dbOperatorType = DbOperatorType.ofCode(filter.getOper());
        if (dbOperatorType == null) {
            return filter.getOper();
        }
        switch (dbOperatorType) {
            case NOTEQUAL:
                return "<>";
            default:
                return dbOperatorType.getCode();
        }
    }


}
